# TODO: Add comment
# 
# Author: guochun
###############################################################################


IMP=function(community){
	
}

IMPtree=function(filename){
	data=read.csv(filename)
	ind=apply(data[,c(4,5,6)],1,sum,na.rm=TRUE)
	ind=tapply(ind,data[,3],sum,na.rm=TRUE)/sum(ind)
	height=tapply(data[,7],data[,3],sum,na.rm=TRUE)/sum(data[,7],na.rm=T)
	cover=tapply(data[,8],data[,3],sum,na.rm=TRUE)/sum(data[,8],na.rm=T)
	
	imv=(ind+height+cover)/3
	
	S=length(unique(data[,3]))
	shannon=-sum(imv*log2(imv))
	simpson=1-sum(imv^2)
	pielous=shannon/log(S)
	re=list(imv,S,shannon,simpson,pielous)
	names(re)=c("important value","richness","shannon","simpson","pielous")
	re=list(re)
	names(re)=filename
	return(re)
}